<template>
  <div class="toolbar">
    <el-pagination
      background
      layout="prev, pager, next"
      :page-count="$store.state.pageSum"
      @current-change="currentChange"
    ></el-pagination>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    actionName: {
      type: String,
      default: null
    },
    // 向下传值时，如果要设置默认值，默认值时一个引用类型，default应该写一个函数，该函数返回的值才是你的默认值
    params: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  data() {
    return {};
  },
  watch: {},
  computed: {},
  methods: {
    currentChange(pageIndex = 1) {
      // console.log(pageIndex);
      this.$store.dispatch(this.actionName, {
        ...this.params,
        ...{
          pageIndex
        }
      });
    }
  },
  created() {},
  mounted() {
    this.currentChange()
    // this.$store.dispatch(this.actionName);
  }
};
</script>
<style lang="scss" scoped>
</style>